package cn.tedu.car.backend.vehicleCombo.service.impl;

import cn.tedu.car.backend.vehicle.pojo.dto.VehicleSaveParam;
import cn.tedu.car.backend.vehicle.pojo.entity.Vehicle;
import cn.tedu.car.backend.vehicleCombo.mapper.VehicleComboMapper;
import cn.tedu.car.backend.vehicleCombo.pojo.dto.VehicleComboPrarm;
import cn.tedu.car.backend.vehicleCombo.pojo.dto.VehicleComboQuery;
import cn.tedu.car.backend.vehicleCombo.pojo.entity.VehicleCombo;
import cn.tedu.car.backend.vehicleCombo.pojo.vo.VehicleComboVO;
import cn.tedu.car.backend.vehicleCombo.service.VehicleComboService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Slf4j
@Service
public class VehicleComboServiceImpl implements VehicleComboService {
    @Autowired
    VehicleComboMapper vehicleComboMapper;

    @Override
    public List<VehicleComboVO> selectVehicleCombo(VehicleComboQuery vehicleComboQuery) {
        log.debug("查询套餐信息combo={}",vehicleComboQuery);
        List<VehicleComboVO> list=vehicleComboMapper.selectCombo(vehicleComboQuery);
        return list;
    }

    @Override
    public void saveVehicle(VehicleComboPrarm vehicleComboPrarm) {
        log.debug("查询套餐信息combo={}",vehicleComboPrarm);
        VehicleCombo vehicleCombo=new VehicleCombo();
        BeanUtils.copyProperties(vehicleComboPrarm,vehicleCombo);
        if(vehicleCombo.getId()==null){
            vehicleComboMapper.insert(vehicleCombo);
        }else {
            vehicleComboMapper.update(vehicleCombo);
        }
    }

    @Override
    public void deleteVehicleCombo(Long id) {
        vehicleComboMapper.deleteById(id);
    }
}
